package com.ardf.mapper;

import com.ardf.entity.Grade;
import com.ardf.entity.dto.GradeTableDto;
import com.ardf.entity.dto.StartGamePersonTableDto;
import com.ardf.entity.dto.StartGameRelayTableDto;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author ShiYunHao
 * @since 2025-01-06
 */
public interface GradeMapper extends BaseMapper<Grade> {
    /**
     * 分页
     */
    Page<GradeTableDto> searchAll(Page<GradeTableDto> page, @Param("competitionId") Long competitionId,
                                  @Param("projectId") Long projectId,
                                  @Param("isLastResultDecided") Boolean isLastResultDecided);


    /**
     * 开始比赛个人分页
     */
    Page<StartGamePersonTableDto> startGameSearchAllPerson(Page<StartGamePersonTableDto> page,
                                                           @Param("projectId") Long projectId,
                                                           @Param("groupId") Long groupId,
                                                           @Param("isTerminal") Boolean isTerminal);

    /**
     * author:容伟洪
     * time:2025-3-6
     * description：查询某条具体的成绩信息,涵盖多种其他信息
     */
    StartGamePersonTableDto startGameSearchOnlyPerson(@Param("gradeId") Long gradeId);

    /**
     * author:容伟洪
     * time:2025-3-6
     * description：查询某条具体的成绩信息,涵盖多种其他信息
     */
    StartGameRelayTableDto startGameSearchOnlyTeam(@Param("gradeId") Long gradeId);


    /**
     * 开始比赛接力分页
     */
    Page<StartGameRelayTableDto> startGameSearchAllRelay(Page<StartGameRelayTableDto> page,
                                                         @Param("projectId") Long projectId,
                                                         @Param("groupId") Long groupId,
                                                         @Param("isTerminal") Boolean isTerminal);

    Grade selectGradeByProIdAndAthId(@Param("projectId") Long projectId,
                                     @Param("athleteId") Long athleteId);

    Grade selectGradeByProIdAndTId(@Param("projectId") Long projectId,
                                     @Param("teamId") Long athleteId);


    /**
     * 获得有效的成绩信息
     */
    List<Grade> listPersonEffectiveOrNot(@Param("status") Byte status,
                                         @Param("projectId") Long projectId,
                                         @Param("groupId") Long groupId);

    List<Grade> listRelayEffectiveOrNot(@Param("status") Byte status,
                                        @Param("projectId") Long projectId,
                                        @Param("groupId") Long groupId);
}
